package com.ljl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.web.client.RestTemplate;

/**
 * 启动类
 * @author Administrator
 */
@EnableScheduling
@EnableWebSecurity
@SpringBootApplication
public class FytxDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(FytxDemoApplication.class, args);
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public ObjectMapper setupJsonFilter(){
        ObjectMapper mapper = new ObjectMapper();
        String[] beanProperties = new String[]{"password"};
        String nonPasswordFilterName = "non-password";
        FilterProvider filterProvider = new SimpleFilterProvider()
                .addFilter(nonPasswordFilterName, SimpleBeanPropertyFilter.serializeAllExcept(beanProperties));
        mapper.setFilterProvider(filterProvider);
        return mapper;
    }
}
